// SINGULARITY HTML5 GAME ENGINE
// -----------------------------
// Copyright(c) 2013 by Codenova.pl

define(function () {
    var Event = function(eventType, obj, objEvent) {
        this.EventType = eventType;
        this.EventProperties = objEvent;
        this.Object = obj;
    };

    Event.prototype = {
        AttachEvent: function() {
            // Depending on EventType attach to the object
            // properties on different rules
            switch(this.EventType) {
                case 'beforeRender':
                    Object.defineProperty(this.Object, 'BeforeRender', {
                        enumerable: true,
                        configurable: false,
                        writable: false,
                        value: this.EventProperties
                    });
                    break;
                case 'click':
                    // Create new properties
                    Object.defineProperty(this.Object, 'Clickable', {
                        enumerable: true,
                        configurable: false,
                        writable: false,
                        value: true
                    });

                    Object.defineProperty(this.Object, 'Click', {
                        enumerable: true,
                        configurable: false,
                        writable: false,
                        value: this.EventProperties
                    });
                    break;
                case 'hover':
                    // Create new properties
                    Object.defineProperty(this.Object, 'Hoverable', {
                        enumerable: true,
                        configurable: false,
                        writable: false,
                        value: true
                    });

                    Object.defineProperty(this.Object, 'Hover', {
                        enumerable: true,
                        configurable: false,
                        writable: false,
                        value: this.EventProperties
                    });
                    break;
                default:
                    break;
            }
        },

        Create: function(eventType, obj, objEvent) {
            return new Event(eventType, obj, objEvent);
        }
    };

    return Event.prototype.Create;
});